package cn.weakup.thread.callback;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

/**
 * @author Dawn
 * @version 1.0.0
 * @desc
 * @date 2022/5/4
 */
public class FutureTaskTest {

    public static void main(String[] args) throws Exception{
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        FutureTask<String> future = new FutureTask<>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "返回结果";
            }
        });

        executorService.execute(future);

        System.out.println(future.get());
        executorService.shutdown();
    }

}
